<template>
  <div id="app">
    <!-- 测试Tosat -->
    <transition name="slide">
      <Toast v-show="isShowToast"></Toast>
    </transition>

    <TopBar :key="topBarKeyValue"></TopBar>
    <Header></Header>
    <router-view @updateKey="updateKeyFn" />
    <Footer></Footer>
    <Login v-show="isShowLoginModal"></Login>
  </div>
</template>
<script>
import TopBar from '@/components/TopBar.vue';
import Header from '@/components/Header.vue';
import Footer from '@/components/Footer.vue';
import Login from '@/components/Login.vue';
import Toast from '@/components/Toast.vue';
import { mapState } from 'vuex';
import { JingpinAPI } from '@/request/api';
export default {
  data() {
    return {
      topBarKeyValue: 0,
    };
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModal.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },
  components: {
    TopBar,
    Header,
    Footer,
    Login,
    Toast,
  },
  async created() {
    let res = await JingpinAPI();
    // console.log(res);
  },
  watch: {
    '$route.path': {
      handler(newVal, oldVal) {
        this.topBarKeyValue++;
        // console.log(this.topBarKeyValue);
      },
    },
  },
  methods: {
    updateKeyFn() {
      this.topBarKeyValue++;
    },
  },
};
</script>

<style lang="less">
// #app {
//   font-family: Avenir, Helvetica, Arial, sans-serif;
//   -webkit-font-smoothing: antialiased;
//   -moz-osx-font-smoothing: grayscale;
//   text-align: center;
//   color: #2c3e50;
// }
/* 入场的起始状态 = 离场的结束状态 */
.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
